﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Utils.Extention;
#region Version Info
/* ========================================================================
* 【本页面功能概述】
*
* 作者：wangjianfeng 创建时间：2012/9/19 17:18:19
* 文件名：search.cs
*
* 修改者： 时间：
* 修改说明：
* ========================================================================
*/
#endregion
namespace ChinaLeg.Web
{
    public partial class search : System.Web.UI.Page
    {
        protected string s;
        protected int recordCount;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Request.QueryString["s"].ToTrim().IsNullOrEmpty())
            {
                s = HttpUtility.UrlDecode( Request.QueryString["s"].ToTrim());
                if (!this.IsPostBack)
                {
                    //ChinaLeg.Cache.Category.Instance.GetModel(catid, out title, out  keyWrods, out  description, out  bgImage);

                    Top1.BgImage = "/images/banner_list.jpg";
                    //adScroll = ChinaLeg.Cache.ScrollFocusPicture.Instance.GetList(catid);

                    //int parentid = ChinaLeg.Cache.Category.Instance.GetParentId(catid);
                    Top1.CatId = 0;
                    //hlCatParent.Text = hlCatParent1.Text = ChinaLeg.Cache.Category.Instance.GetCatName(parentid);
                    //hlCatParent.NavigateUrl = hlCatParent1.NavigateUrl = ChinaLeg.Web.Lib.WebLinks.GetCatLinks(parentid);

                    //hlCat.Text = hlCat1.Text = ChinaLeg.Cache.Category.Instance.GetCatName(catid);
                    //hlCat.NavigateUrl = hlCat1.NavigateUrl = ChinaLeg.Web.Lib.WebLinks.GetListLinks(catid);


                    int pageSize = 10;
                    int pageIndex = 1;
                    if (!Request.QueryString["page"].ToTrim().IsNullOrEmpty())
                    {
                        pageIndex = Request.QueryString["page"].ToInt32();
                    }


                    rptList.DataSource = ChinaLeg.BLL.News.Instance.GetList(string.Format(" and (charindex('{0}',Title) >0 or charindex('{0}',KeyWords) >0 or charindex('{0}',Description) >0) ", s), pageSize, pageIndex, out recordCount);
                    rptList.DataBind();

                    divPager.InnerHtml = Utils.Common.Pager.GetPager(recordCount, pageSize, pageIndex, string.Format("search.html?s={0}&", HttpUtility.UrlEncode( s) ));

                }

            }
        }
    }
}